<script lang="ts" setup>
import HomePanel from './home-panel.vue'
import useStore from '@/store';
import HomeSkeleton from './home-skeleton.vue'
// 导入数据懒加载
import {useLazyDate} from '@/uitils/hooks'
const {home}=useStore()
// target与组件ref绑定 
const target=useLazyDate(()=>{
  home.getHotList()
})
</script>
<template>
  <div class="home-new">
    <HomePanel ref="target" title="人气推荐" sub-title="人气爆款 不容错过">
      <!-- 具名插槽  -->
      <template #right><XtxMore path="/" /></template>
      <!-- 面板内容 Transition(V3内置动画组件)-->
     <Transition name="fade">
       <ul class="goods-list" v-if="home.hotGoodsList.length>0">
        <li v-for="item in home.hotGoodsList" :key="item.id">
          <RouterLink :to="`/goods/${item.id}`">
            <img
              v-lazy="item.picture"
              alt=""
            />
            <p class="name ellipsis">{{item.title}}</p>
            <p class="price">&yen;{{item.alt}}</p>
          </RouterLink>
        </li>
      </ul>
      <!-- 骨架屏组件 -->
      <HomeSkeleton v-else></HomeSkeleton>
     </Transition>
    </HomePanel>
  </div>
</template>

<style scoped lang="less">
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>
